package com.example.generator.utils;

import java.io.File;
import java.io.IOException;

/**
 * @author：QPX
 * @date：2024-01-26-17:44
 */
public class FileUtil {
    public static void create(String path) throws Exception {
        File file = new File(path);
        String message;
        if (file.exists()) {
            if (!file.isDirectory()) {
                message = "File " + file + " exists and is not a directory. Unable to create directory.";
                throw new IOException(message);
            }
        } else if (!file.mkdirs() && !file.isDirectory()) {
            message = "Unable to create directory " + file;
            throw new IOException(message);
        }
    }
}
